
namespace FastFood.Business.Logic
{
	using System;
	using System.Collections.Generic;
	using EDOSwit.Entity;
	using FastFood.Business.Entities;
	using FastFood.DataAccess;
    using System.Linq;

	/// <summary>
	/// Represents the Manager of Proveedores.
	/// </summary>
	[Serializable]
	public class ProveedoresManager : Singleton<ProveedoresManager>
	{
        #region Methods

        /// <summary>
        /// Selects all records from the Proveedores table by RUC or razon social.
        /// </summary>
        public IList<Proveedores> ListarByNombreOrRUC(string nombre, string RUC)
        {
            try
            {
                if(!String.IsNullOrEmpty(nombre))
                {
                    return ProveedoresData.Instancia.ListarByNombre(nombre).Reverse().ToList();
                }
                else if(!String.IsNullOrEmpty(RUC))
                {
                    return ProveedoresData.Instancia.ListarByRUC(RUC).Reverse().ToList();
                }
                else return ProveedoresData.Instancia.Listar().Reverse().ToList();
            }
            catch (Exception) { throw; }
        }

		/// <summary>
		/// Selects all records from the Proveedores table.
		/// </summary>
		public IList<Proveedores> Listar()
		{
			try
			{
                return ProveedoresData.Instancia.Listar().Reverse().ToList();
			}
			catch (Exception) { throw; }
		}

		/// <summary>
		/// Selects a single record from the Proveedores table.
		/// </summary>
		public Proveedores Obtener(short proveedorID)
		{
			try
			{
				return ProveedoresData.Instancia.Obtener(proveedorID);
			}
			catch (Exception) { throw; }
		}

		/// <summary>
		/// Saves a record to the Proveedores table.
		/// </summary>
		public short Agregar(Proveedores proveedores)
		{
			try
			{
				return ProveedoresData.Instancia.Agregar(proveedores);
			}
			catch (Exception) { throw; }
		}

		/// <summary>
		/// Updates a record in the Proveedores table.
		/// </summary>
		public bool Modificar(Proveedores proveedores)
		{
			try
			{
				return ProveedoresData.Instancia.Modificar(proveedores);
			}
			catch (Exception) { throw; }
		}

		/// <summary>
		/// Deletes a record from the Proveedores table by its primary key.
		/// </summary>
		public bool Eliminar(short proveedorID)
		{
			try
			{
				return ProveedoresData.Instancia.Eliminar(proveedorID);
			}
			catch (Exception) { throw; }
		}

		#endregion
	}
}
